package com.dream.technology.mockTest;

import com.alibaba.fastjson.JSONObject;
import com.dream.technology.controller.RcRuleCollectionController;
import com.dream.technology.db.entity.vo.VoRuleCollection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * 描述：
 *
 * @author chen_q_i@163.com
 * 2019/3/16 : 13:10.
 * @version : 1.0
 */

@ActiveProfiles("dev")
@RunWith(SpringRunner.class)
@SpringBootTest
public class CollectionConT {

    @Autowired
    private RcRuleCollectionController rcRuleCollectionController;


    private MockMvc mvc;

    @Before
    public void setup(){
        mvc = MockMvcBuilders.standaloneSetup(rcRuleCollectionController).build();
    }


    String s = "{\"rcRuleCollection\":{\"collectionRule\":\"E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&(A|B|W)&X&Y&Z&A1&A2&A3&A4\"},\"rcRuleCollectionItem\":[{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":112,\"itemAlias\":\"A\",\"ruleId\":124,\"ruleName\":\"运营商姓名验证\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":113,\"itemAlias\":\"B\",\"ruleId\":125,\"ruleName\":\"运营商身份证号验证\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":116,\"itemAlias\":\"E\",\"ruleId\":128,\"ruleName\":\"手机近半年平均消费\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":117,\"itemAlias\":\"F\",\"ruleId\":129,\"ruleName\":\"互通号码个数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":118,\"itemAlias\":\"G\",\"ruleId\":130,\"ruleName\":\"月均静默天数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":119,\"itemAlias\":\"H\",\"ruleId\":131,\"ruleName\":\"入网时长限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":120,\"itemAlias\":\"I\",\"ruleId\":132,\"ruleName\":\"近一个月静默天数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":121,\"itemAlias\":\"J\",\"ruleId\":133,\"ruleName\":\"本人号码命中逾期情况\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":122,\"itemAlias\":\"K\",\"ruleId\":134,\"ruleName\":\"紧急联系人1逾期情况\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":123,\"itemAlias\":\"L\",\"ruleId\":135,\"ruleName\":\"紧急联系人2逾期情况\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":124,\"itemAlias\":\"M\",\"ruleId\":136,\"ruleName\":\"近1个月被叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":125,\"itemAlias\":\"N\",\"ruleId\":137,\"ruleName\":\"近1个月主叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":126,\"itemAlias\":\"O\",\"ruleId\":138,\"ruleName\":\"近3个月被叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":127,\"itemAlias\":\"P\",\"ruleId\":139,\"ruleName\":\"近3个月主叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":128,\"itemAlias\":\"Q\",\"ruleId\":141,\"ruleName\":\"近6个月被叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":129,\"itemAlias\":\"R\",\"ruleId\":140,\"ruleName\":\"近6个月主叫次数限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":130,\"itemAlias\":\"S\",\"ruleId\":142,\"ruleName\":\"近一月主叫时长限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":131,\"itemAlias\":\"T\",\"ruleId\":143,\"ruleName\":\"近一个月被叫时长限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":132,\"itemAlias\":\"U\",\"ruleId\":144,\"ruleName\":\"近三个月主叫时长限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-01-24 18:26:33\",\"enabled\":true,\"id\":133,\"itemAlias\":\"V\",\"ruleId\":145,\"ruleName\":\"近三个月被叫时长限制\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":344,\"itemAlias\":\"W\",\"ruleId\":329,\"ruleName\":\"天机报告是否实名认证\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":345,\"itemAlias\":\"X\",\"ruleId\":330,\"ruleName\":\"天机报告黑名单次数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":346,\"itemAlias\":\"Y\",\"ruleId\":331,\"ruleName\":\"天机号码命中黑名单\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":347,\"itemAlias\":\"Z\",\"ruleId\":332,\"ruleName\":\"天机本人逾期数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":348,\"itemAlias\":\"A1\",\"ruleId\":333,\"ruleName\":\"机构TJ查询次数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":349,\"itemAlias\":\"A2\",\"ruleId\":334,\"ruleName\":\"查询用户相关企业数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":350,\"itemAlias\":\"A3\",\"ruleId\":335,\"ruleName\":\"本人尝试申请次数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"},{\"collectionId\":45,\"createDate\":\"2019-03-18 10:13:30\",\"enabled\":true,\"id\":351,\"itemAlias\":\"A4\",\"ruleId\":336,\"ruleName\":\"用户联系人黑名单数\",\"status\":false,\"updateDate\":\"2019-03-18 10:49:11\"}]}";
    @Test
    public  void  checkorDocT() throws Exception {


        String url = "/risk/admin/rule_collection/checkForDoc";
        VoRuleCollection collection = JSONObject.parseObject(s, VoRuleCollection.class);
//        Consolesole.info("ss","---------->>>>>--------------------------");
        this.mvc.perform(post(url)
                .contentType(MediaType.APPLICATION_JSON_UTF8)
                .content(JSONObject.toJSONString(collection)))
//                .param("ss","ssssss"))
                .andDo(print())
                .andExpect(status().isOk())
                .andDo(print());


//        Console.info("ss","---------------------------------------");
    }
}
